<template>
  <div class="detail">
    <HmHeader :showArrow="true" @clickleft="fn">
      面经详细
      <!-- <template #right> 搜索 </template> -->
    </HmHeader>
    <!-- detail组件
    <van-button type="primary" :round="true" color="pink" @click="fn"
      >主要按钮</van-button
    >
    <van-button type="info">信息按钮</van-button>
    <van-button type="mini">信息按钮</van-button>
    <van-button type="default">信息按钮</van-button>
    <van-button type="warning" :loading="true" loading-text="快马加鞭"
      >信息按钮</van-button
    > -->

    <h1>{{ obj.stem }}</h1>
    <div class="info">
      <span>{{ obj.createdAt }}</span>
      <span>|</span>
      <span>{{ obj.views }} 浏览量</span>
      <span>|</span>
      <span>{{ obj.likeCount }} 点赞数</span>
    </div>

    <div class="qian">
      <img :src="obj.avatar" alt="" />
      <span>{{ obj.creator }}</span>
    </div>

    <div class="content">
      {{ obj.content }}
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "HmDetail",

  data() {
    return {
      obj: {},
    };
  },
  created() {
    console.log(this.$route.query.id);
    this.getdetail(this.$route.query.id);
  },
  methods: {
    async getdetail(id) {
      const res = await axios({
        method: "get",
        url: "http://interview-api-t.itheima.net/h5/interview/show?id=" + id,
        headers: {
          Authorization: `Bearer ${localStorage.getItem("token")}`,
        },
      });
      this.obj = res.data.data;
      console.log(res);
    },
    fn() {
      this.$router.back();
      alert("点击了返回");
    },
  },
};
</script>

<style lang="less" scoped>
.qian {
  display: flex;
  align-items: center;

  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
}

.content {
  text-indent: 2em;
}
</style>
